package com.smiier.skin.ui;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.RelativeLayout;
import android.widget.TextView;
import cn.o.app.ui.OImageView;
import cn.skinapp.R;

import com.lidroid.xutils.BitmapUtils;
import com.smiier.skin.net.entity.User;
import com.smiier.skin.utils.CommonUtility;

public class PersonDetailView extends RelativeLayout implements OnClickListener {
	private OImageView mImage;
	private TextView mName;
	private TextView mMessage;
	private Button mButton;
	private User mUser;

	public PersonDetailView(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
		// TODO Auto-generated constructor stub
	}

	public PersonDetailView(Context context, AttributeSet attrs) {
		super(context, attrs);
		// TODO Auto-generated constructor stub
	}

	public PersonDetailView(Context context) {
		super(context);
		// TODO Auto-generated constructor stub
	}

	@Override
	protected void onFinishInflate() {
		super.onFinishInflate();
		mImage = (OImageView) findViewById(R.id.img_patient_icon);
		mName = (TextView) findViewById(R.id.text_patient_name);
		mMessage = (TextView) findViewById(R.id.text_patient_id);
		mButton = (Button) findViewById(R.id.guanzhu);
		mButton.setOnClickListener(this);
	}

	public void setMessage(User mUser, BitmapUtils mBitmapUtils, String pic) {
		this.mUser = mUser;
		StringBuilder sb = new StringBuilder();
		sb.append(CommonUtility.sex.get(mUser.Sex)).append("，")
				.append(CommonUtility.getAgeByBirthday(mUser.Birth.toString()))
				.append("岁")// .append("，").append(mUser.Nation).append("，")
		// .append(CommonUtility.marry.get(mUser.Marital_Status))
		// .append("，").append("现居" + mUser.Province)
		;
		mMessage.setText(sb.toString());
		// mName.setText(mUser.Name);
		// mBitmapUtils.display(mImage, GlobalSettings.SERVER_IMG_URL +
		// mUser.Pic
		// + Constant.IMG_TH, new OBitmapLoadCallBack<View>());
		if(CommonUtility.isDoctor()){
		mName.setText(mUser.Name);
		}
		CommonUtility.displayHeadImage(mImage, mBitmapUtils, pic, getContext()
				.getResources(), mUser.Sex);
	}

	@Override
	public void onClick(View v) {

	}

}
